<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue.js</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="vue-app">
        <h1> v-for </h1>

        <!-- 数组下标 -->
        <!-- {{ characters[0] }}
        {{ characters[1] }}
        {{ characters[2] }} -->

        <!-- 数组遍历 -->
        <ul>
            <!-- :key 要唯一 默认会赋予一个唯一的id -->
            <li v-for="character in characters" :key="character.id">
                {{ character }}
            </li>
        </ul>

        <ul>
            <li v-for="(user,index) in users">
                {{index + 1}}.{{ user.name }} - {{ user.age }}
            </li>
        </ul>

        <!-- template 和 v-for遍历对象 -->
        <template v-for="(user,index) in users">
            <div v-for="(val,key) in user">
                <p>{{key}}-{{val}}</p>
            </div>
        </template>
    </div>

    <script src="app.js"></script>
</body>
</html>